package com.cuitrip.component.para.proxy;

import android.text.TextUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 登录相关逻辑
 * Created by ak on 15/9/23.
 */
public class ParaProxy {


    private static ParaProxy sInstance;

    public static ParaProxy getInstance() {
        if (null == sInstance)
            sInstance = new ParaProxy();
        return sInstance;
    }

    public String outputPara(List<CharSequence> paraList){
        if (paraList == null || paraList.size() == 0){
            return "";
        }else if (paraList.size() == 1){
            return paraList.get(0).toString();
        }else{
            return TextUtils.join("\n",paraList);
        }
    }

    public CharSequence[] getParaArray(String paraOutput){
        if (paraOutput.contains("\n")){
            return TextUtils.split(paraOutput, "\n");
        }else{
            return new String[]{paraOutput};
        }

    }

    public ArrayList<CharSequence> getParaList(String paraOutput){
        ArrayList<CharSequence> strings = new ArrayList<>();
        if (!TextUtils.isEmpty(paraOutput)){
            CharSequence[] stringArray = getParaArray(paraOutput);
            strings.addAll(Arrays.asList(stringArray));
        }
        return strings;
    }


}
